<?php

$dbhost = "localhost:3306";
$databasename = "questdb";
$dbuser="root";
$dbpassword="default";

$fName = $_POST['fName'];
$lName = $_POST['lName'];
$uName = $_POST['username'];
$passWord = $_POST['password'];
$email = $_POST['Email'];
$date = $_POST['bd_year'].'-'.$_POST['bd_month'].'-'.$_POST['bd_day'];
$dob = date('Y-m-d', strtotime($date));
$sex = $_POST['sex'];

// Connect to the MySQL
	$link = @mysql_connect($dbhost, $dbuser, $dbpassword);
    if (!$link)
		{
		die('Not connected : ' . mysql_error());
		}
    
    // select test as the current db
    $db_selected = mysql_select_db($databasename, $link);
    if (!$db_selected)
		{
		die ("Database not selected : " . mysql_error());
		}
		
	//query for inserting data into database
	$query = "INSERT INTO user_table (fName, lName, Username, Password, Email, DOB, Gender)
				VALUES ('$fName', '$lName', '$uName', '$passWord', '$email', '$dob', '$sex')";

			
	if(!mysql_query($query, $link))
		{
		echo 'Query failed. '.mysql_error();
		exit();
		}
     else
		{
		echo "<center>Thank you for your registration. Please log-in to search pages and images seamless</center><br>";
		echo "<center><a href=\"home.php\">Go to Home Page</a></center>";
		}
	@mysql_connect(close);
	
?>